const express = require("express");

const router = express.Router();

const ArticleCateModel = require("../../model/articleCateModel");

router.get("/", (req, res) => {
    res.send("API接口V1");
})

router.get("/focus", (req, res) => {
    // 只支持ajax请求
    /* res.send({
        success: true,
        message: "获取成功"
    }); */

    /* res.json({
        success: true,
        message: "获取成功"
    }); */

    // 支持jsonp和ajax请求
    res.jsonp({
        success: true,
        message: "获取成功"
    });
})

router.get("/articleCate", async (req, res) => {
    const result = await ArticleCateModel.find({});
    res.send({
        success: true,
        message: "获取成功",
        result
    });
})

router.post("/doLogin", async (req, res) => {
    const body = req.body;
    res.send({
        success: true,
        message: "登陆成功",
        result: body
    });
})

router.put("/editUser", async (req, res) => {
    const body = req.body;
    res.send({
        success: true,
        message: "修改用户成功",
        result: body
    });
})

router.delete("/deleteUser", async (req, res) => {
    const body = req.body;
    res.send({
        success: true,
        message: "修改用户成功",
        result: body
    });
})

module.exports = router